<?php
/**
 * 金币产品模板
 */
$golds = ProductGold::model()->getGoldPorduct($model->game_id);
$server = Yii::app()->request->getQuery('server');
?>
<div class="btn-group">
    <a class="btn dropdown-toggle" data-toggle="dropdown" href="#">
        <?php echo!empty($server) ? $server : 'Choose Server'; ?>
        <span class="caret"></span>
    </a>
    <ul class="dropdown-menu">
        <?php
        foreach ($game_servers as $v) {
            echo CHtml::openTag('li');
            echo CHtml::link($v->title, '?server=' . $v->title);
            echo CHtml::closeTag('li');
        }
        ?>
    </ul>
</div>
<hr/>
<?php
if (empty($server)) {
    echo $model->info;
} else {
    $serverModel = ProductCategory::model()->getServerByName($server, $model->game_id);
    if (empty($serverModel)) {
        throw new CHttpException(404, 'The Game server does not exist.');
    }
    ?>
    <table class="table table-hover">
        <thead>
            <tr>
                <th>Product</th>
                <th>Price</th>
                <th>Buy</th>
            </tr>
        </thead>
        <tbody>
            <?php
            foreach ($golds as $gold):
                //$price = ProductGold::model()->getGoldPrice($gold, $serverModel->id);
                $price = $this->changeCurrency($gold->gold_num * $gold->gold_discount * $serverModel->price);
                ?>
                <tr>
                    <td><strong><?php echo $gold->gold_name; ?></strong></td>
                    <td class="price"><?php echo $price['tag'] . $price['price']; ?></td>
                    <td>
                        <form>
                            <input type="hidden" name="game" value="<?php echo $model->game_id;?>">
                            <input type="hidden" name="server" value="<?php echo $serverModel->id;?>"> 
                            <input type="hidden" name="product_type" value="<?php echo $model->product_model;?>">
                            <input type="hidden" name="product" value="<?php echo $gold->id;?>">
                            <input class="add-to-cart getAttr btn" rel="buy" onclick="" type="button" value="Buy Now">
                        </form>

                    </td>
                </tr>
                <?php
            endforeach;
            ?>
        </tbody>
    </table>
    <?php
}
?>
